package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.example.demo.po.User;
import com.example.demo.service.UserServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 实现一码通的查询功能
 */
@RestController
@RequestMapping(value = "/index")
public class Index {

    private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(Index.class);

    @Autowired
    private UserServiceI userServiceI;

    /**
     * @param idCardNo 身份证号码
     * @return 查询结果
     */
    @GetMapping("getDataByIdCardNo")
    public String getDataByIdCardNo(String idCardNo){
        LOG.info("start");
        User userInfo = userServiceI.getByCardNo(idCardNo);
        if (userInfo !=null){
            LOG.info("end");
            return JSON.toJSONString(userInfo);
        }
        return "getDataByIdCardNo";
    }

    /**
     *
     * @param cellPhoneNo 手机号
     * @return 查询结果
     */
    @GetMapping("/getDataByCellPhoneNo")
    public String getDataByCellPhoneNo(String cellPhoneNo){
        // TODO: 2022/1/13  完善这个
        return "getDataByCellPhoneNo";
    }

}
